/**
 * @file implements DataStorageWriter
 * @author CORSAIR <vladimir.corsair@gmail.com>
 * @version 1.0
 * @interface for DataWriter
 */

/**
 * Write local data with localStorage
 * @returns {DataStorageWriter}
 */
var DataStorageWriter = function() {
    this.set = function(key, value) {
        if (typeof value === "object") {
          value = JSON.stringify(value);
        }
        localStorage.setItem(key, value);
    };
    
    this.get = function (key) {
        var value = localStorage.getItem(key);
        if (!value) {return;}
        if (value[0] === "{") {
          value = JSON.parse(value);
        }
        return value;
    };
    
    this.remove = function (key) {
        localStorage.removeItem(key);
    };
};